#include <iostream>
#include <csignal>
#include <unistd.h>
#include <cstdlib>
#include <sys/types.h>


void signalhandler(int signum){
	std::cout<<"获得一个信号 "<<signum<<std::endl;
	sleep(1);
}

int main(){
	signal(SIGINT, signalhandler);
	int cnt = 0;
	while(true){
		std::cout<<"hello  world :"<<cnt++<<" times"<<std::endl;
		std::cout<<"pid = "<<getpid()<<std::endl;
		sleep(1);
	}

	return 0;
}